package com.hoow.shakoow.utils

import android.annotation.SuppressLint
import com.hoow.shakoow.ai.data.RevObjShakeUserInfo
import com.hoow.shakoow.extend.*


/** 用户登录状态管理工具 */
object UserStateUtil {

    //user info
    var mUserInfo: RevObjShakeUserInfo? = null

    //sp token
    var mToken: String

    //sp user id
    var mMobile: String

    //sp mobile
    var mUserId: String

    //sp is Ad Source
    var mIsAdSource: String

    init {
        mToken = SpUtil.getToken()
        mUserId = SpUtil.getUserId()
        mMobile = SpUtil.getMobile()
        mIsAdSource =
            SpUtil.getIsAdSourceUser()
    }

    /**
     * 判断是否是渠道流量
     */
    fun isDidLogin(): Boolean {
        return (mToken.isNotBlank())
    }

    /** 保存 token */
    @SuppressLint("ApplySharedPref")
    fun saveToken(gToken: String) {
        mToken = gToken
        SpUtil.saveToken(gToken)
    }

    /** 保存 user id */
    @SuppressLint("ApplySharedPref")
    fun saveUserId(gUserId: String) {
        mUserId = gUserId
        SpUtil.saveUserId(gUserId)
    }

    /** 保存mobile */
    @SuppressLint("ApplySharedPref")
    fun saveMobile(gMobile: String) {
        mMobile = gMobile
        SpUtil.saveMobile(gMobile)
    }


}